package Dao;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import model.Lernbuero;
import model.Lernbuero_gruppe;

public class Dao_Lernbuerogruppe 
{


public Lernbuero_gruppe getLernebuero_gruppe(String lbg)
{
	Connection conn=ConnectionProvider.getConnection();
	PreparedStatement statement=null;
	ResultSet rs=null;
	Lernbuero_gruppe le= new Lernbuero_gruppe();
	
	String sql="select * from lernbuerogruppe where=lbgruppeID?";
	try {
		statement = conn.prepareStatement(sql);
		statement.setString(1, lbg);
		rs=statement.executeQuery();
		if (rs.next())
		{
          
			le.setLernbgBEZ(rs.getString("lernbgbz"));
		
		   
		}	

		}catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}   
		finally {
			try {
				rs.close();
				statement.close();
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		;
		return le;
	}

public void getLernbuero_gruppeaendern (Lernbuero_gruppe lb)
{
	
	
	Connection conn=ConnectionProvider.getConnection();
	String sql="update lernbuerogruppe set lernbgbz=? where lbgruppeID=?";
   
	try {
		
		
		PreparedStatement statement = conn.prepareStatement(sql);
		statement.setString(1, lb.getLernbgBEZ());
		
		statement.executeUpdate();
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}   
	finally {
		try {
			conn.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
public Lernbuero_gruppe getLernbueroanlegen(Lernbuero_gruppe lb)
{
	Connection conn=ConnectionProvider.getConnection();
	String sql="insert into lernbuerogruppe  VALUES (?, ?)";
    try {
		PreparedStatement statement = conn.prepareStatement(sql);
		statement.setInt(1, lb.getLbgruppeID());
		statement.setString(2, lb.getLernbgBEZ());
		statement.executeUpdate();
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}   
	finally {
		try {
			conn.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	return lb;
}
	public Lernbuero_gruppe getLbgruppeID(int int1) 
	{
		// TODO Auto-generated method stub
		return new Lernbuero_gruppe();
	}

}
